package com.uniflow.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uniflow.common.Result;
import com.uniflow.entity.DataSyncLog;
import com.uniflow.service.DataSyncLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 数据同步日志管理控制器
 */
@Api(tags = "数据同步日志管理")
@RestController
@RequestMapping("/api/v1/data-sync-log")
public class DataSyncLogController {
    
    @Autowired
    private DataSyncLogService dataSyncLogService;
    
    /**
     * 分页查询数据同步日志
     */
    @ApiOperation("分页查询数据同步日志")
    @GetMapping("/page")
    public Result<IPage<DataSyncLog>> getPageList(
            @ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam("页大小") @RequestParam(defaultValue = "10") Integer pageSize,
            @ApiParam("同步任务ID") @RequestParam(required = false) String syncId,
            @ApiParam("状态") @RequestParam(required = false) String status,
            @ApiParam("触发方式") @RequestParam(required = false) String triggerType,
            @ApiParam("开始时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
            @ApiParam("结束时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
            @ApiParam("关键词") @RequestParam(required = false) String keyword,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        IPage<DataSyncLog> result = dataSyncLogService.getPageList(pageNum, pageSize, syncId, status,
                triggerType, startTime, endTime, keyword, tenantId);
        return Result.success(result);
    }
    
    /**
     * 根据ID查询数据同步日志
     */
    @ApiOperation("根据ID查询数据同步日志")
    @GetMapping("/{id}")
    public Result<DataSyncLog> getById(@ApiParam("数据同步日志ID") @PathVariable String id,
                                       HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        DataSyncLog log = dataSyncLogService.getById(id, tenantId);
        return Result.success(log);
    }
    
    /**
     * 根据同步任务ID查询日志
     */
    @ApiOperation("根据同步任务ID查询日志")
    @GetMapping("/sync/{syncId}")
    public Result<List<DataSyncLog>> getBySyncId(@ApiParam("同步任务ID") @PathVariable String syncId,
                                                 HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getBySyncId(syncId, tenantId);
        return Result.success(list);
    }
    
    /**
     * 根据批次号查询日志
     */
    @ApiOperation("根据批次号查询日志")
    @GetMapping("/batch/{batchNo}")
    public Result<List<DataSyncLog>> getByBatchNo(@ApiParam("批次号") @PathVariable String batchNo,
                                                  HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getByBatchNo(batchNo, tenantId);
        return Result.success(list);
    }
    
    /**
     * 根据状态查询日志
     */
    @ApiOperation("根据状态查询日志")
    @GetMapping("/status/{status}")
    public Result<List<DataSyncLog>> getByStatus(@ApiParam("状态") @PathVariable String status,
                                                 HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getByStatus(status, tenantId);
        return Result.success(list);
    }
    
    /**
     * 根据触发方式查询日志
     */
    @ApiOperation("根据触发方式查询日志")
    @GetMapping("/trigger-type/{triggerType}")
    public Result<List<DataSyncLog>> getByTriggerType(@ApiParam("触发方式") @PathVariable String triggerType,
                                                      HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getByTriggerType(triggerType, tenantId);
        return Result.success(list);
    }
    
    /**
     * 根据触发人查询日志
     */
    @ApiOperation("根据触发人查询日志")
    @GetMapping("/triggered-by/{triggeredBy}")
    public Result<List<DataSyncLog>> getByTriggeredBy(@ApiParam("触发人ID") @PathVariable String triggeredBy,
                                                      HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getByTriggeredBy(triggeredBy, tenantId);
        return Result.success(list);
    }
    
    /**
     * 查询正在运行的日志
     */
    @ApiOperation("查询正在运行的日志")
    @GetMapping("/running")
    public Result<List<DataSyncLog>> getRunningLogs(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getRunningLogs(tenantId);
        return Result.success(list);
    }
    
    /**
     * 查询失败的日志
     */
    @ApiOperation("查询失败的日志")
    @GetMapping("/failed")
    public Result<List<DataSyncLog>> getFailedLogs(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getFailedLogs(tenantId);
        return Result.success(list);
    }
    
    /**
     * 查询最近的日志
     */
    @ApiOperation("查询最近的日志")
    @GetMapping("/recent")
    public Result<List<DataSyncLog>> getRecentLogs(@ApiParam("限制数量") @RequestParam(defaultValue = "10") Integer limit,
                                                   HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getRecentLogs(limit, tenantId);
        return Result.success(list);
    }
    
    /**
     * 查询指定同步任务的最新日志
     */
    @ApiOperation("查询指定同步任务的最新日志")
    @GetMapping("/sync/{syncId}/latest")
    public Result<DataSyncLog> getLatestBySyncId(@ApiParam("同步任务ID") @PathVariable String syncId,
                                                 HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        DataSyncLog log = dataSyncLogService.getLatestBySyncId(syncId, tenantId);
        return Result.success(log);
    }
    
    /**
     * 查询指定同步任务的最后成功日志
     */
    @ApiOperation("查询指定同步任务的最后成功日志")
    @GetMapping("/sync/{syncId}/last-success")
    public Result<DataSyncLog> getLastSuccessBySyncId(@ApiParam("同步任务ID") @PathVariable String syncId,
                                                      HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        DataSyncLog log = dataSyncLogService.getLastSuccessBySyncId(syncId, tenantId);
        return Result.success(log);
    }
    
    /**
     * 查询指定同步任务的最后失败日志
     */
    @ApiOperation("查询指定同步任务的最后失败日志")
    @GetMapping("/sync/{syncId}/last-failure")
    public Result<DataSyncLog> getLastFailureBySyncId(@ApiParam("同步任务ID") @PathVariable String syncId,
                                                      HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        DataSyncLog log = dataSyncLogService.getLastFailureBySyncId(syncId, tenantId);
        return Result.success(log);
    }
    
    /**
     * 查询长时间运行的日志
     */
    @ApiOperation("查询长时间运行的日志")
    @GetMapping("/long-running")
    public Result<List<DataSyncLog>> getLongRunningLogs(@ApiParam("分钟数") @RequestParam(defaultValue = "60") Integer minutes,
                                                        HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getLongRunningLogs(minutes, tenantId);
        return Result.success(list);
    }
    
    /**
     * 查询执行时间超过阈值的日志
     */
    @ApiOperation("查询执行时间超过阈值的日志")
    @GetMapping("/slow")
    public Result<List<DataSyncLog>> getSlowLogs(@ApiParam("耗时阈值（毫秒）") @RequestParam Long durationThreshold,
                                                 HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> list = dataSyncLogService.getSlowLogs(durationThreshold, tenantId);
        return Result.success(list);
    }
    
    /**
     * 创建数据同步日志
     */
    @ApiOperation("创建数据同步日志")
    @PostMapping
    public Result<DataSyncLog> createLog(@RequestBody DataSyncLog log,
                                         HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        log.setTenantId(tenantId);
        DataSyncLog result = dataSyncLogService.createLog(log);
        return Result.success(result);
    }
    
    /**
     * 更新数据同步日志
     */
    @ApiOperation("更新数据同步日志")
    @PutMapping("/{id}")
    public Result<DataSyncLog> updateLog(@ApiParam("数据同步日志ID") @PathVariable String id,
                                         @RequestBody DataSyncLog log,
                                         HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        log.setId(id);
        log.setTenantId(tenantId);
        DataSyncLog result = dataSyncLogService.updateLog(log);
        return Result.success(result);
    }
    
    /**
     * 开始执行
     */
    @ApiOperation("开始执行")
    @PostMapping("/start")
    public Result<DataSyncLog> startExecution(@RequestBody StartExecutionRequest request,
                                               Authentication authentication,
                                               HttpServletRequest httpRequest) {
        String currentUserId = authentication.getName();
        String tenantId = (String) httpRequest.getAttribute("tenantId");
        DataSyncLog log = dataSyncLogService.startExecution(request.getSyncId(), request.getSyncName(),
                request.getTriggerType(), currentUserId, authentication.getName(), tenantId);
        return Result.success(log);
    }
    
    /**
     * 完成执行
     */
    @ApiOperation("完成执行")
    @PostMapping("/{id}/complete")
    public Result<Boolean> completeExecution(@ApiParam("数据同步日志ID") @PathVariable String id,
                                              @RequestBody CompleteExecutionRequest request) {
        boolean result = dataSyncLogService.completeExecution(id, request.getStatus(),
                request.getResult(), request.getErrorMessage());
        return Result.success(result);
    }
    
    /**
     * 更新执行进度
     */
    @ApiOperation("更新执行进度")
    @PutMapping("/{id}/progress")
    public Result<Boolean> updateProgress(@ApiParam("数据同步日志ID") @PathVariable String id,
                                          @RequestBody UpdateProgressRequest request) {
        boolean result = dataSyncLogService.updateProgress(id, request.getProgress(),
                request.getCurrentStep(), request.getStepProgress());
        return Result.success(result);
    }
    
    /**
     * 更新执行统计
     */
    @ApiOperation("更新执行统计")
    @PutMapping("/{id}/stats")
    public Result<Boolean> updateExecutionStats(@ApiParam("数据同步日志ID") @PathVariable String id,
                                                 @RequestBody UpdateExecutionStatsRequest request) {
        boolean result = dataSyncLogService.updateExecutionStats(id, request.getProcessedRecords(),
                request.getSuccessRecords(), request.getFailureRecords(), request.getSkippedRecords(),
                request.getInsertRecords(), request.getUpdateRecords(), request.getDeleteRecords());
        return Result.success(result);
    }
    
    /**
     * 更新错误信息
     */
    @ApiOperation("更新错误信息")
    @PutMapping("/{id}/error")
    public Result<Boolean> updateError(@ApiParam("数据同步日志ID") @PathVariable String id,
                                       @RequestBody UpdateErrorRequest request) {
        boolean result = dataSyncLogService.updateError(id, request.getErrorMessage(), request.getErrorStack());
        return Result.success(result);
    }
    
    /**
     * 批量删除日志
     */
    @ApiOperation("批量删除日志")
    @DeleteMapping("/batch")
    public Result<Boolean> batchDeleteLogs(@RequestBody BatchDeleteRequest request) {
        boolean result = dataSyncLogService.batchDeleteLogs(request.getIds());
        return Result.success(result);
    }
    
    /**
     * 根据同步任务ID删除日志
     */
    @ApiOperation("根据同步任务ID删除日志")
    @DeleteMapping("/sync/{syncId}")
    public Result<Boolean> deleteBySyncId(@ApiParam("同步任务ID") @PathVariable String syncId) {
        boolean result = dataSyncLogService.deleteBySyncId(syncId);
        return Result.success(result);
    }
    
    /**
     * 删除过期日志
     */
    @ApiOperation("删除过期日志")
    @DeleteMapping("/expired")
    public Result<Boolean> deleteExpiredLogs(
            @ApiParam("过期时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime expireTime,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        boolean result = dataSyncLogService.deleteExpiredLogs(expireTime, tenantId);
        return Result.success(result);
    }
    
    /**
     * 清理指定状态的日志
     */
    @ApiOperation("清理指定状态的日志")
    @DeleteMapping("/cleanup")
    public Result<Boolean> cleanupByStatus(
            @ApiParam("状态") @RequestParam String status,
            @ApiParam("时间之前") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beforeTime,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        boolean result = dataSyncLogService.cleanupByStatus(status, beforeTime, tenantId);
        return Result.success(result);
    }
    
    /**
     * 获取日志统计信息
     */
    @ApiOperation("获取日志统计信息")
    @GetMapping("/statistics")
    public Result<Map<String, Object>> getStatistics(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> statistics = dataSyncLogService.getStatistics(tenantId);
        return Result.success(statistics);
    }
    
    /**
     * 按状态统计日志数量
     */
    @ApiOperation("按状态统计日志数量")
    @GetMapping("/statistics/status")
    public Result<List<Map<String, Object>>> getStatsByStatus(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsByStatus(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 按触发方式统计日志数量
     */
    @ApiOperation("按触发方式统计日志数量")
    @GetMapping("/statistics/trigger-type")
    public Result<List<Map<String, Object>>> getStatsByTriggerType(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsByTriggerType(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 按同步任务统计日志数量
     */
    @ApiOperation("按同步任务统计日志数量")
    @GetMapping("/statistics/sync-id")
    public Result<List<Map<String, Object>>> getStatsBySyncId(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsBySyncId(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 按触发人统计日志数量
     */
    @ApiOperation("按触发人统计日志数量")
    @GetMapping("/statistics/triggered-by")
    public Result<List<Map<String, Object>>> getStatsByTriggeredBy(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsByTriggeredBy(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 按时间统计日志数量
     */
    @ApiOperation("按时间统计日志数量")
    @GetMapping("/statistics/time")
    public Result<List<Map<String, Object>>> getStatsByTime(
            @ApiParam("开始时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
            @ApiParam("结束时间") @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
            @ApiParam("时间单位") @RequestParam String timeUnit,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsByTime(startTime, endTime, timeUnit, tenantId);
        return Result.success(stats);
    }
    
    /**
     * 按月份统计日志数量
     */
    @ApiOperation("按月份统计日志数量")
    @GetMapping("/statistics/month")
    public Result<List<Map<String, Object>>> getStatsByMonth(@ApiParam("年份") @RequestParam Integer year,
                                                              HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> stats = dataSyncLogService.getStatsByMonth(year, tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取执行成功率统计
     */
    @ApiOperation("获取执行成功率统计")
    @GetMapping("/statistics/success-rate")
    public Result<Map<String, Object>> getSuccessRateStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getSuccessRateStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取平均执行时间统计
     */
    @ApiOperation("获取平均执行时间统计")
    @GetMapping("/statistics/avg-execution-time")
    public Result<Map<String, Object>> getAvgExecutionTimeStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getAvgExecutionTimeStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取执行性能统计
     */
    @ApiOperation("获取执行性能统计")
    @GetMapping("/statistics/performance")
    public Result<Map<String, Object>> getPerformanceStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getPerformanceStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取错误统计
     */
    @ApiOperation("获取错误统计")
    @GetMapping("/statistics/error")
    public Result<Map<String, Object>> getErrorStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getErrorStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取今日执行统计
     */
    @ApiOperation("获取今日执行统计")
    @GetMapping("/statistics/today")
    public Result<Map<String, Object>> getTodayStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getTodayStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取本周执行统计
     */
    @ApiOperation("获取本周执行统计")
    @GetMapping("/statistics/weekly")
    public Result<Map<String, Object>> getWeeklyStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getWeeklyStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取本月执行统计
     */
    @ApiOperation("获取本月执行统计")
    @GetMapping("/statistics/monthly")
    public Result<Map<String, Object>> getMonthlyStats(HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        Map<String, Object> stats = dataSyncLogService.getMonthlyStats(tenantId);
        return Result.success(stats);
    }
    
    /**
     * 获取同步任务执行趋势
     */
    @ApiOperation("获取同步任务执行趋势")
    @GetMapping("/trend/execution")
    public Result<List<Map<String, Object>>> getExecutionTrend(
            @ApiParam("同步任务ID") @RequestParam String syncId,
            @ApiParam("天数") @RequestParam(defaultValue = "7") Integer days,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> trend = dataSyncLogService.getExecutionTrend(syncId, days, tenantId);
        return Result.success(trend);
    }
    
    /**
     * 获取同步任务性能趋势
     */
    @ApiOperation("获取同步任务性能趋势")
    @GetMapping("/trend/performance")
    public Result<List<Map<String, Object>>> getPerformanceTrend(
            @ApiParam("同步任务ID") @RequestParam String syncId,
            @ApiParam("天数") @RequestParam(defaultValue = "7") Integer days,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> trend = dataSyncLogService.getPerformanceTrend(syncId, days, tenantId);
        return Result.success(trend);
    }
    
    /**
     * 获取同步任务错误趋势
     */
    @ApiOperation("获取同步任务错误趋势")
    @GetMapping("/trend/error")
    public Result<List<Map<String, Object>>> getErrorTrend(
            @ApiParam("同步任务ID") @RequestParam String syncId,
            @ApiParam("天数") @RequestParam(defaultValue = "7") Integer days,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<Map<String, Object>> trend = dataSyncLogService.getErrorTrend(syncId, days, tenantId);
        return Result.success(trend);
    }
    
    /**
     * 查询执行历史
     */
    @ApiOperation("查询执行历史")
    @GetMapping("/history")
    public Result<List<DataSyncLog>> getExecutionHistory(
            @ApiParam("同步任务ID") @RequestParam String syncId,
            @ApiParam("限制数量") @RequestParam(defaultValue = "10") Integer limit,
            HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> history = dataSyncLogService.getExecutionHistory(syncId, limit, tenantId);
        return Result.success(history);
    }
    
    /**
     * 查询执行详情
     */
    @ApiOperation("查询执行详情")
    @GetMapping("/{id}/detail")
    public Result<DataSyncLog> getExecutionDetail(@ApiParam("数据同步日志ID") @PathVariable String id,
                                                  HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        DataSyncLog detail = dataSyncLogService.getExecutionDetail(id, tenantId);
        return Result.success(detail);
    }
    
    /**
     * 查询相关执行
     */
    @ApiOperation("查询相关执行")
    @GetMapping("/related")
    public Result<List<DataSyncLog>> getRelatedExecutions(@ApiParam("批次号") @RequestParam String batchNo,
                                                          HttpServletRequest request) {
        String tenantId = (String) request.getAttribute("tenantId");
        List<DataSyncLog> related = dataSyncLogService.getRelatedExecutions(batchNo, tenantId);
        return Result.success(related);
    }
    
    // 请求数据结构
    
    public static class StartExecutionRequest {
        private String syncId;
        private String syncName;
        private String triggerType;
        
        public String getSyncId() { return syncId; }
        public void setSyncId(String syncId) { this.syncId = syncId; }
        public String getSyncName() { return syncName; }
        public void setSyncName(String syncName) { this.syncName = syncName; }
        public String getTriggerType() { return triggerType; }
        public void setTriggerType(String triggerType) { this.triggerType = triggerType; }
    }
    
    public static class CompleteExecutionRequest {
        private String status;
        private String result;
        private String errorMessage;
        
        public String getStatus() { return status; }
        public void setStatus(String status) { this.status = status; }
        public String getResult() { return result; }
        public void setResult(String result) { this.result = result; }
        public String getErrorMessage() { return errorMessage; }
        public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
    }
    
    public static class UpdateProgressRequest {
        private Integer progress;
        private String currentStep;
        private Integer stepProgress;
        
        public Integer getProgress() { return progress; }
        public void setProgress(Integer progress) { this.progress = progress; }
        public String getCurrentStep() { return currentStep; }
        public void setCurrentStep(String currentStep) { this.currentStep = currentStep; }
        public Integer getStepProgress() { return stepProgress; }
        public void setStepProgress(Integer stepProgress) { this.stepProgress = stepProgress; }
    }
    
    public static class UpdateExecutionStatsRequest {
        private Long processedRecords;
        private Long successRecords;
        private Long failureRecords;
        private Long skippedRecords;
        private Long insertRecords;
        private Long updateRecords;
        private Long deleteRecords;
        
        public Long getProcessedRecords() { return processedRecords; }
        public void setProcessedRecords(Long processedRecords) { this.processedRecords = processedRecords; }
        public Long getSuccessRecords() { return successRecords; }
        public void setSuccessRecords(Long successRecords) { this.successRecords = successRecords; }
        public Long getFailureRecords() { return failureRecords; }
        public void setFailureRecords(Long failureRecords) { this.failureRecords = failureRecords; }
        public Long getSkippedRecords() { return skippedRecords; }
        public void setSkippedRecords(Long skippedRecords) { this.skippedRecords = skippedRecords; }
        public Long getInsertRecords() { return insertRecords; }
        public void setInsertRecords(Long insertRecords) { this.insertRecords = insertRecords; }
        public Long getUpdateRecords() { return updateRecords; }
        public void setUpdateRecords(Long updateRecords) { this.updateRecords = updateRecords; }
        public Long getDeleteRecords() { return deleteRecords; }
        public void setDeleteRecords(Long deleteRecords) { this.deleteRecords = deleteRecords; }
    }
    
    public static class UpdateErrorRequest {
        private String errorMessage;
        private String errorStack;
        
        public String getErrorMessage() { return errorMessage; }
        public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
        public String getErrorStack() { return errorStack; }
        public void setErrorStack(String errorStack) { this.errorStack = errorStack; }
    }
    
    public static class BatchDeleteRequest {
        private List<String> ids;
        
        public List<String> getIds() { return ids; }
        public void setIds(List<String> ids) { this.ids = ids; }
    }
}